<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<!--    引入layui -->
<link href="../../assets/layui-v2.5.6/css/layui.css" rel="stylesheet">
<script src="../../assets/layui-v2.5.6/layui.all.js"></script>


<div style="margin: 20px;" id="poet_add">
    <form class="layui-form"  lay-filter="add_form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" placeholder="" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">字号</label>
                <div class="layui-input-inline">
                    <input type="text" name="courtesyName" placeholder=""
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <input type="radio" name="sex" value="男" title="男" checked>
                    <input type="radio" name="sex" value="女" title="女">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">年龄</label>
                <div class="layui-input-inline">
                    <input type="text" name="age" placeholder="" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">出生日期</label>
                <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="birthYear" placeholder="年"
                           autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="birthMonth" placeholder="月" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="birthDay" placeholder="日" autocomplete="off" class="layui-input">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">出生地</label>
            <div class="layui-input-block">
                <input type="text" name="birthplace" placeholder=""
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">死亡日期</label>
                <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="deathYear" placeholder="年"
                           autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="deathMonth" placeholder="月" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="deathDay" placeholder="日" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">死亡地</label>
            <div class="layui-input-block">
                <input type="text" name="deathplace" placeholder=""
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">生平简介</label>
            <div class="layui-input-block">
                <textarea name="briefLifeAccount" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">主要成就</label>
            <div class="layui-input-block">
                <textarea name="achievement" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="display: flex">
                <!--                <div style="display: inline-block;flex: 1"></div>-->
                <div style="display: inline-block;flex: 1"></div>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
<!--                <button class="layui-btn" onclick="sub()">提交</button>-->
                <button  type="button" class="layui-btn" onclick="sub()">提交</button>
                <div style="display: inline-block;flex: 1"></div>
            </div>
        </div>
    </form>
</div>
<script>
    let form = layui.form;
    form.render(); //更新全部
    //新增提交
    function sub() {
        let param = form.val("add_form");
        $.post("/dataManagement/poet/add", param, function (data) {
            if (data.code == 0) {
                parent.layer.closeAll();
                parent.layer.msg(data.msg, {time: 2000});
                //刷新表格
                parent.reload();
            } else {
                parent.layer.msg(data.msg);
            }
        });
    }
</script>